Improve error handling for login connection issues#143
Improve error handling for login connection issues#143feichashao wants to merge 2 commits intoopenshift:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feichashao The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest-required |
| return fmt.Errorf("cluster %s is hibernating, login failed", clusterKey) | ||
| } | ||
| // Check API connection with configured proxy | ||
| err = bpConfig.CheckAPIConnection() |
There was a problem hiding this comment.
Any reason to remove bpConfig.CheckAPIConnection(), which is ping to api end-point and validates the connection?
backplane-cli/pkg/cli/config/config.go
Line 92 in bcd5b3e
There was a problem hiding this comment.
I tired changing the logic to only perform CheckAPIConnection only when the error returned is errLoginConnection but fails the test cases.
if errors.Is(err, errLoginConnection) {
connectionErr := bpConfig.CheckAPIConnection()
if connectionErr != nil {
return fmt.Errorf("cannot connect to backplane API URL, check if you need to use a proxy/VPN to access backplane: %v", connectionErr)
}
}
Test result:
• Failure [1.378 seconds]
Login command
/Users/feichashao/git/github/backplane-cli/cmd/ocm-backplane/login/login_test.go:28
check cluster login
/Users/feichashao/git/github/backplane-cli/cmd/ocm-backplane/login/login_test.go:187
should fail when BP API timeouts [It]
/Users/feichashao/git/github/backplane-cli/cmd/ocm-backplane/login/login_test.go:294
Expected
<string>: can't login to cluster: unable to connect to backplane api: dial tcp i/o timeout
to contain substring
<string>: cannot connect to backplane API URL
while I was trying to tweak the test case, I think we can instead skip testing the api connectivity as the error message from doLogin has already did a "test" on the apiserver, we can expose the actual network error + a hint about proxy/vpn to make the error logic simpler.
There was a problem hiding this comment.
I guess this PR fixed the error overwriting issue.
|
@feichashao: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
Closing this as #151 can solve this problem. |
What type of PR is this?
Bug
What this PR does / Why we need it?
If login returns an authentication issues (4xx), and we don't have a proxy set, the current logic will show the error
cannot connect to backplane API URL, check if you need to use a proxy/VPN to access backplane.The PR changes the error handling to only print such error when the error returned from
doLoginis exactly a network issue. And if the error returned fromdoLoginis a network issue, we don't need to test the connection again, thus removing thebpConfig.CheckAPIConnectioncheck.Which Jira/Github issue(s) does this PR fix?
https://issues.redhat.com/browse/OSD-17374
Resolves #
Special notes for your reviewer
Tested locally.
For connection issue, it will show
For authentication issue, it will show
Pre-checks (if applicable)